/**
 * 租户管理
 */

import request from '@/utils/request'

/**
 * 查询租户列表
 * @param {*} params 
 */
export function listTenant(params = {}) {
  return request({
    url: '/system/tenant/list',
    method: 'get',
    params: params
  })
}

/**
 * 新增租户
 * @param {*} params 
 */
export function addTenant(params = {}) {
  return request({
    url: '/system/tenant/add',
    method: 'post',
    data: params
  })
}

/**
 * 修改租户
 * @param {*} params 
 * @returns 
 */
export function updateTenant(params = {}) {
  return request({
    url: '/system/tenant/update',
    method: 'put',
    data: params
  })
}

/**
 * 导出租户列表
 * @param {*} params 
 */
export function exportTenant(params = {}) {
  return request({
    url: '/system/tenant/export',
    method: 'get',
    params: params
  })
}

/**
 * 上级租户下拉选择
 * @param {*} params 
 */
export function parentListTenant(params = {}) {
  return request({
    url: '/system/tenant/parentList',
    method: 'get',
    params: params
  })
}

/**
 * 重置密码
 * @param {*} params 
 */
export function resetPwdTenant(params = {}) {
  return request({
    url: '/system/tenant/resetPwd?tenantId=' + params.tenantId,
    method: 'put',
    data: {}
  })
}

/**
 * 客户下拉接口
 * @param {*} params 
 */
export function customerOptionSelect(params = {}) {
  let url = '/basic/data/customer/optionSelect';
  if (params && params.name && params.name.length > 0) {
    url = url + '?name=' + params.name;
    delete params.name;
  }
  return request({
    url: url,
    method: 'post',
    data: params
  })
}

/**
 * 获取关联客户列表
 * @param {*} params 
 * @returns 
 */
export function correlationCustomers(params = {}) {
  return request({
    url: '/system/tenant/customerList',
    method: 'get',
    params: params
  })
}

/**
 * 获取关联供应商下拉
 * @param {*} params 
 * @returns 
 */
export function supplierOptionSelect(params = {}) {
  return request({
    url: '/basic/data/supplier/optionSelect',
    method: 'get',
    params: params
  })
}

/**
 * 获取关联供应商列表
 * @param {*} params 
 * @returns 
 */
export function supplierList(params = {}) {
  return request({
    url: '/system/tenant/supplierList',
    method: 'get',
    params: params
  })
}